import 'dart:io';

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:sp_util/sp_util.dart';
import 'package:yp/router.dart';

import '../../helper.dart';
import 'logic.dart';
import 'state.dart';

class SplashPage extends StatelessWidget {
  final SplashLogic logic = Get.put(SplashLogic());
  final SplashState state = Get.find<SplashLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: GetBuilder<SplashLogic>(
        builder: (logic) {
          return Stack(
            alignment: Alignment.center,
            children: [
              Positioned(
                bottom: 100.w,
                child: Image.asset(
                  "assets/images/logo@3x.png",
                  width: 350.w,
                ),
              ),
              Container(
                color: Colors.black.withOpacity(.3),
                child: SimpleDialog(
                  title: Text(
                    '个人信息保护',
                    style: TextStyle(
                      color: Color(0xff030303),
                      fontSize: setWidth(28),
                      fontWeight: FontWeight.w600,
                    ),
                    textAlign: TextAlign.center,
                  ),
                  titleTextStyle: TextStyle(
                      fontSize: 16,
                      fontWeight: FontWeight.bold,
                      color: Colors.blue),
                  children: [
                    Column(
                      children: [
                        Container(
                          padding: EdgeInsets.symmetric(
                            horizontal: setWidth(30),
                          ),
                          decoration: BoxDecoration(
                              borderRadius:
                                  BorderRadius.all(Radius.circular(100)),
                              color: Colors.white),
                          child: Container(
                            height: 300,
                            child: SingleChildScrollView(
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  Text('感谢您对壹品慧一直以来的信任！'),
                                  SizedBox(
                                    height: setWidth(20),
                                  ),
                                  Container(
                                    child: RichText(
                                      text: TextSpan(
                                        children: [
                                          TextSpan(
                                            text: '我们依据最新的监管要求更新了',
                                            style: TextStyle(
                                              color: Color(0xff999999),
                                              fontSize: setWidth(22),
                                            ),
                                          ),
                                          TextSpan(
                                              text: '《壹品慧隐私权政策》',
                                              style: TextStyle(
                                                color: Color(0xffEA5504),
                                                fontSize: setWidth(22),
                                              ),
                                              recognizer: TapGestureRecognizer()
                                                ..onTap = () {
                                                  Get.toNamed(RouteConfig.webview,
                                                      arguments: {
                                                        "url":
                                                            "https://img.zrhsh.com/zrhshgg/treaty/yszc-yph.html",
                                                      });
                                                }),
                                          TextSpan(
                                            text: '和',
                                            style: TextStyle(
                                              color: Color(0xff999999),
                                              fontSize: setWidth(22),
                                            ),
                                          ),
                                          TextSpan(
                                            text: '《壹品慧服务协议》',
                                            style: TextStyle(
                                              color: Color(0xffEA5504),
                                              fontSize: setWidth(22),
                                            ),
                                            recognizer: TapGestureRecognizer()
                                              ..onTap = () {
                                                Get.toNamed(RouteConfig.webview,
                                                    arguments: {
                                                      "url":
                                                          "http://img.zrhsh.com/zrhshgg/treaty/fwxy-20220113.html",
                                                    });
                                              },
                                          ),
                                          TextSpan(
                                            text: '（点击了解更新后的详细内容），特向您说明如下：',
                                            style: TextStyle(
                                              color: Color(0xff999999),
                                              fontSize: setWidth(22),
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ),
                                  Text(
                                    '1、为向您提供缴费相关基本功能，我们会收集、使用必要的信息；',
                                    style: TextStyle(
                                      color: Color(0xff999999),
                                      fontSize: setWidth(22),
                                    ),
                                  ),
                                  SizedBox(
                                    height: setWidth(20),
                                  ),
                                  Text(
                                    '2、为保障您的账号与使用安全，您需要授权我们读取本机识别码，您有权拒绝或取消授权，取消后不会影响您使用我们提供的其他服务；',
                                    style: TextStyle(
                                      color: Color(0xff999999),
                                      fontSize: setWidth(22),
                                    ),
                                  ),
                                  SizedBox(
                                    height: setWidth(20),
                                  ),
                                  Text(
                                    '3、为在慧生活APP首页向您展示所在位置附近营业厅信息，您需要授权我们获取您的位置权限，您有权拒绝或取消授权，取消后不会影响您使用我们提供的其他服务；',
                                    style: TextStyle(
                                      color: Color(0xff999999),
                                      fontSize: setWidth(22),
                                    ),
                                  ),
                                  SizedBox(
                                    height: setWidth(20),
                                  ),
                                  Text(
                                    '4、我们会采取业界先进的安全措施保护您的信息安全；',
                                    style: TextStyle(
                                      color: Color(0xff999999),
                                      fontSize: setWidth(22),
                                    ),
                                  ),
                                  SizedBox(
                                    height: setWidth(20),
                                  ),
                                  Text(
                                    '5、未经您同意，我们不会从第三方处获取、共享或向其提供您的信息；',
                                    style: TextStyle(
                                      color: Color(0xff999999),
                                      fontSize: setWidth(22),
                                    ),
                                  ),
                                  SizedBox(
                                    height: setWidth(20),
                                  ),
                                  Text(
                                    '6、您可以查询、更正您的个人信息；',
                                    style: TextStyle(
                                      color: Color(0xff999999),
                                      fontSize: setWidth(22),
                                    ),
                                  ),
                                  SizedBox(
                                    height: setWidth(20),
                                  ),
                                  Text(
                                    '7、您如果选择不同意，则默认退出当前APP',
                                    style: TextStyle(
                                      color: Color(0xff999999),
                                      fontSize: setWidth(22),
                                    ),
                                  ),
                                  SizedBox(
                                    height: setWidth(40),
                                  ),
                                ],
                              ),
                            ),
                          ),
                        ),
                        Container(
                          padding:
                              EdgeInsets.symmetric(horizontal: setWidth(30)),
                          child: Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              GestureDetector(
                                onTap: () async {
                                  exit(0);
                                },
                                child: Container(
                                  width: setWidth(200),
                                  height: setWidth(60),
                                  decoration: BoxDecoration(
                                    borderRadius: BorderRadius.all(
                                      Radius.circular(100),
                                    ),
                                    border:
                                        Border.all(color: Color(0xff666666)),
                                  ),
                                  child: Center(
                                    child: Text(
                                      "不同意",
                                      style: TextStyle(
                                        fontSize: setWidth(24),
                                        color: Color(0xff666666),
                                      ),
                                    ),
                                  ),
                                ),
                              ),
                              GestureDetector(
                                onTap: () {
                                  SpUtil.putBool("isAgree", true);
                                  Get.offAndToNamed(RouteConfig.main);
                                },
                                child: Container(
                                  width: setWidth(200),
                                  height: setWidth(60),
                                  decoration: BoxDecoration(
                                    color: Color(0xffEA5504),
                                    borderRadius: BorderRadius.all(
                                      Radius.circular(100),
                                    ),
                                    border:
                                        Border.all(color: Color(0xffEA5504)),
                                  ),
                                  child: Center(
                                    child: Text(
                                      "同意",
                                      style: TextStyle(
                                        fontSize: setWidth(24),
                                        color: Colors.white,
                                      ),
                                    ),
                                  ),
                                ),
                              )
                            ],
                          ),
                        )
                      ],
                    )
                  ],
                  backgroundColor: Colors.white,
                  elevation: 10,
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(20),
                  ),
                ),
              ),
            ],
          );
        },
      ),
    );
  }
}
